const { timeStamp } = require('console')
const { Contract } = require('ethers')
const {ethers} = require('hardhat')
const hre = require('hardhat')

const property = require('../.env.bsc')

let addrObj = JSON.parse(JSON.stringify(property.addr))

module.exports.upgrade = async (contractName, contractAddress) => {
    console.log('upgrade >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', contractName)
    const contractFactory = await ethers.getContractFactory(contractName)
    const contract = await upgrades.upgradeProxy(contractAddress, contractFactory, {})
    console.log('upgrade:', contract.address)
}

module.exports.config = async (name) =>{
    const contract = (await ethers.getContractFactory('ConfigBase')).attach(addrObj.configBaseAddress);
    r = await contract.nameOf(ethers.utils.toUtf8Bytes(name));
    console.log(r);
}

module.exports.openBox = async () =>{
    const contract = (await ethers.getContractFactory('NFTBox')).attach(addrObj.nftBoxAddress);
    r = await contract.openBox();
    console.log(r);
}

module.exports.openBoxByAdmin = async () =>{
    const contract = (await ethers.getContractFactory('NFTBox')).attach(addrObj.nftBoxAddress);
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.openBoxByAdmin(8,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    
    console.log(r);
}

module.exports.propOf = async (addr) =>{
    const contract = (await ethers.getContractFactory('PoolNode')).attach(addrObj.poolNodeAddress);
    r = await contract.propOf(addr);
    console.log(r);
}

module.exports.setAsset = async () =>{
    const contract = (await ethers.getContractFactory("Assets")).attach(addrObj.assetsAddress)
    r = await contract.setAuth("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4", true)
    // r = await contract.assetsOf("0xCe772e18a9e6d51b51fFDad0aD8a1DCd9007e71A",10010)
    r = await contract.setAssetsOf("0x00e11357307e25DC9edf7518BD54310Fbf007068",10010,1000)
    r = await contract.setAssetsOf("0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4",10010,1000)
    r = await contract.setAssetsOf("0xcc45D6175B43199fB0d10e35390761C4d22Fb9Ab",10010,1000)
    r = await contract.setAssetsOf("0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4",10010,1000)
    r = await contract.setAssetsOf("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4",10010,1000)
    r = await contract.setAssetsOf("0x2c69b6025aaE914Ff676076d699BE862A93d884C",10010,1000)
    console.log(r);
}

module.exports.assetsOf = async () =>{
    const contract = (await ethers.getContractFactory("Assets")).attach(addrObj.assetsAddress)
    // r = await contract.setAuth("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4", true)
    // r = await contract.assetsOf("0xCe772e18a9e6d51b51fFDad0aD8a1DCd9007e71A",10010)
    r = await contract.assetsOf("0x87EB185e1fB41F43cE84cD9Ae75597f5B12c3c5C",10010)
    console.log(r);
}


module.exports.updateStorage = async() =>{
    const contract = (await ethers.getContractFactory('NFTBox')).attach(addrObj.nftBoxAddress);
    r = await contract.updateStorage([[2000,130],[1000,220],[200,1200],[50,4000],[10,8000]]);
    console.log(r);
}

module.exports.nftHeroConfig = async() =>{
    const contract = (await ethers.getContractFactory('NFTHero')).attach(addrObj.nftHeroAddress);
    r = await contract.config();
    console.log(r);
}

module.exports.mintTimeOf = async() =>{
    const contract = (await ethers.getContractFactory('NFTHero')).attach(addrObj.nftHeroAddress);
    r = await contract.mintTimeOf(1);
    console.log(r);
}

module.exports.transferFrom = async() =>{
    const contract = (await ethers.getContractFactory('NFTHero')).attach(addrObj.nftHeroAddress);
    r = await contract.setConfig("");
    console.log(r);
}

module.exports.ownerOf = async() =>{
    const contract = (await ethers.getContractFactory('NFTHero')).attach(addrObj.nftHeroAddress);
    r = await contract.ownerOf(1998);
    console.log(r);
}

module.exports.getNFTs = async(addr) =>{
    const contract = (await ethers.getContractFactory('NFTHero')).attach(addrObj.nftHeroAddress);
    r = await contract.getNFTs(addr,0,100);
    console.log(r);
}
module.exports.tokenRarity = async() =>{
    const contract = (await ethers.getContractFactory('NFTHero')).attach(addrObj.nftHeroAddress);
    r = await contract.tokenRarity("0x0D56fe32a9DfeC571d42A837366C69e119FE1974",1);
    console.log(r);
}

module.exports.freeze = async() =>{
    const contract = (await ethers.getContractFactory('NFTHero')).attach(addrObj.nftHeroAddress);
    r = await contract.freeze(10,true);
    console.log(r);
}

module.exports.auth = async(_name,_contract,_account) =>{
    console.log('Inviter setAuth ---------------------------------')
    const contract = (await ethers.getContractFactory(_name)).attach(_contract)
    r = await contract.setAuth(_account, true)
    console.log(r);
}

module.exports.startIDo = async() =>{
    const contract = (await ethers.getContractFactory('IDo')).attach(addrObj.idoAddress);
    r = await contract.startIDo([
        'Tcoin',
        "0x20ee59dFB91216EDE794eC12c5CF259c181FA9f3",
        "210000000000000000000000000",
        "100000000000000000000",
        50,
        "1000000000000000000",
        "100000000000000000000",
        "1000000000000000000000",
        1656056306,
        1658648306,
        "",
        "https://img0.baidu.com/it/u=530426417,2082848644&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
    ]);
    console.log(r);
}


module.exports.endIDo = async() =>{
    const contract = (await ethers.getContractFactory('IDo')).attach(addrObj.idoAddress);
    r = await contract.endIDo("0x20ee59dFB91216EDE794eC12c5CF259c181FA9f3");
    console.log(r);
}

module.exports.invest = async() =>{
    const contract = (await ethers.getContractFactory('IDo')).attach(addrObj.idoAddress);
    r = await contract.invest("0x20ee59dFB91216EDE794eC12c5CF259c181FA9f3","100000000000000000000");
    console.log(r);
}

module.exports.listIDoInfo = async() =>{
    const contract = (await ethers.getContractFactory('IDo')).attach(addrObj.idoAddress);
    r = await contract.listIDoInfo(0,10);
    // r = await contract.idoInfoList(1);
    console.log(r);
}


module.exports.admin = async() =>{
    const contract = (await ethers.getContractFactory('Airdrop')).attach(addrObj.airdropAddress);
    r = await contract.admin();
    console.log(r);
}

// module.exports.receiveAmount = async() =>{
//     const contract = (await ethers.getContractFactory('Airdrop')).attach(addrObj.airdropAddress);
//     r = await contract.receiveAmount();
//     console.log(r);
// }

module.exports.receiveAmount = async() =>{
    const contract = (await ethers.getContractFactory('Airdrop')).attach(addrObj.airdropAddress);
    r = await contract.receiveAmount(1);
    console.log(r);
}

module.exports.setConfig = async() =>{
    const contract = (await ethers.getContractFactory('NFTHero')).attach(addrObj.nftHeroAddress);
    r = await contract.setConfig(addrObj.configBaseAddress);
    console.log(r);
}

module.exports.listInvsetInfo = async() =>{
    const contract = (await ethers.getContractFactory('IDo')).attach(addrObj.idoAddress);
    r = await contract.listInvsetInfo("0x20ee59dFB91216EDE794eC12c5CF259c181FA9f3","0xcfd1586c1fdb6e377533c902bd2ced0ce500def4",0,10);
    console.log(r);
}

module.exports.setConfigNameOf = async()=>{
    console.log('configBase.setConfigNameOf ---------------------------------')
    const contract = (await ethers.getContractFactory('ConfigBase')).attach(addrObj.configBaseAddress)
    console.log(addrObj.configBaseAddress)
    // r = await contract.admin();
    // r = await contract.setAuth(addrObj.adminAddress, true)
    // r = await contract.setAuth(addrObj.auth1Address, true)
    
    // r = await contract.setConfigUint("tcoinPrice","10000000000000000")
    // r = await contract.setConfigUint("poolAmountOneDay","210000000000000000000000");
    // r = await contract.setConfigNameOf(ethers.utils.toUtf8Bytes('nftHero'), "0x73CC3cC42C76eD2afCDD998C4061f9B6b2a8B28e")
    // r = await contract.setConfigNameOf(ethers.utils.toUtf8Bytes("psToken"),addrObj.psTokenAddress);
    r = await contract.setConfigNameOf(ethers.utils.toUtf8Bytes("lpToken"),addrObj.lpTokenAddress);
    // r = await contract.setConfigNameOf(ethers.utils.toUtf8Bytes("usdtToken"),addrObj.usdtTokenAddress);
    // r = await contract.setConfigNameOf(ethers.utils.toUtf8Bytes("lpStakePool"),"0xAfB1306976cA6a4Cf55253EE217B50A05394D0F2");   // 挖矿池子
    // r = await contract.setConfigNameOf(ethers.utils.toUtf8Bytes("idoPool"),"0x0d39b59D2FFBA4a7f703fFb446A28417F6d21e71");       // ido 池子
    // r = await contract.setConfigNameOf(ethers.utils.toUtf8Bytes("inviterPool"),"0xAfB1306976cA6a4Cf55253EE217B50A05394D0F2");   // 推广 池子
    // r = await contract.setConfigNameOf(ethers.utils.toUtf8Bytes("hfPool"),"0x365669425C26e25aD5deEB947687f4729dDfa551");    // 手续费池子
    console.log(r);
}

module.exports.setConfigUint = async() => {
    console.log('configBase.setConfigNameOf ---------------------------------')
    const configBase = (await ethers.getContractFactory('ConfigBase')).attach(addrObj.configBaseAddress)
    r = await configBase.uintOf('poolAmountOneDay')
    // r = await configBase.admin();
    console.log(r);
}

module.exports.hfauth = async() => {
    console.log('configBase.setConfigNameOf ---------------------------------')
    const configBase = (await ethers.getContractFactory('PoolHF')).attach(addrObj.poolHFAddress)
    r = await configBase.auth("0x0d39b59D2FFBA4a7f703fFb446A28417F6d21e71")
    // r = await configBase.admin();
    console.log(r);
}


module.exports.setlpArrays = async()=>{
    console.log('configBase.setConfigNameOf ---------------------------------')
    const configBase = (await ethers.getContractFactory('ConfigBase')).attach(addrObj.configBaseAddress)
    r = await configBase.addConfigBytesArray(ethers.utils.toUtf8Bytes('lpArrays'), ethers.utils.toUtf8Bytes("0xC848dE73EE3B61bdFc9E3c9488837a992eDAfFB9"))
    console.log(r);
}

module.exports.approve = async () => {
    console.log('approve >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
    // const contract =  (await ethers.getContractFactory("ERC20Token")).attach(addrObj.usdtTokenAddress);
    const contract =  (await ethers.getContractFactory("ERC20Token")).attach(addrObj.psTokenAddress);
    
    // r = await contract.approve(addrObj.exchangeAddress,"9999990000000000000000000");
    // r = await contract.approve(addrObj.poolLPAddress,"9999990000000000000000000");
    // r = await contract.approve(addrObj.exchangeAddress,"9999990000000000000000000");
    // // console.log(addrObj.exchangeAddress)
    // r = await contract.approve(addrObj.poolNodeAddress,"9999990000000000000000000");
    // r = await contract.approve(addrObj.idoAddress,"9999990000000000000000000");
    r = await contract.approve("0x0A083b8935C591092Ef15a9331251cccB165C90c","9999990000000000000000000");
    // r = await contract.approve(addrObj.inviterAddress,"9999990000000000000000000");
    // r = await contract.approve(addrObj.poolNFTAddress,"9999990000000000000000000");
    // r = await contract.approve(addrObj.poolHFAddress,"9999990000000000000000000");
    console.log(r)
}

module.exports.listSubInfo = async() =>{
    const contract = (await ethers.getContractFactory('Inviter')).attach(addrObj.inviterAddress);
    r = await contract.listSubInfo("0xc36E7612685901b94189748650D2c5E77dbfFFD0",140,20);
    console.log(r);
}

module.exports.erc20SetLPAddress = async() =>{
    const contract = (await ethers.getContractFactory('ERC20Token')).attach("0x02bAb1082a1Ea084cDf9bfbdbEe99AcD76381947");
    // r = await contract.admin();
    // r = await contract.lpAddress();
    // lpAddress
    r = await contract.addWhiteList("0x65677A572b129d6Ef70b413f0f61161E26e872FF");
    r = await contract.addWhiteList("0x23e47B01d2d39661880B216f698e6307A71A2d18");
    r = await contract.addWhiteList("0x9c11b4094a2f2Cd228A6bbB88ea9A86e5C037516");
    r = await contract.addWhiteList("0x3B00E4D1C49D6D07f73Fd367595b31fd4226Ce3B");
    r = await contract.addWhiteList("0x8200E39464725E7aa47387b89f52E5D1b1BD50CB");
    r = await contract.addWhiteList("0x38d5c961f3ddC3fad3B2eEF2b152df7936fe5A06");
    r = await contract.addWhiteList("0x7DD0C073Cb4f4d3fc6d6843Eeb31437d79a7df61");
    r = await contract.addWhiteList("0xB9Ae5b47060FB3E2509FDFD8D87A276FcF2f4DcB");

    console.log(r);
}


module.exports.inviterConfig = async() =>{
    const contract = (await ethers.getContractFactory('Inviter')).attach(addrObj.inviterAddress);
    r = await contract.config();
    console.log(r);
}


module.exports.lpConfig = async() =>{
    const contract = (await ethers.getContractFactory('PoolLP')).attach(addrObj.poolLPAddress);
    r = await contract.config();
    console.log(r);
}

module.exports.getPending = async() =>{
    const contract = (await ethers.getContractFactory('PoolNFT')).attach(addrObj.poolNodeAddress);
    // r = await contract.getPending("0x0D56fe32a9DfeC571d42A837366C69e119FE1974");
    // r = await contract.getPending("0xdbd237e9ce4817d6bc4826880b1a725f537f8b36");
    r = await contract.config()
    console.log(r);
}

module.exports.stake = async() =>{
    const contract = (await ethers.getContractFactory('PoolLP')).attach(addrObj.poolLPAddress);
    console.log(addrObj.poolLPAddress);
    r = await contract.stake("100000000000000000000","0xC848dE73EE3B61bdFc9E3c9488837a992eDAfFB9");
    console.log(r);
}
module.exports.receiveInterest = async() =>{
    const contract = (await ethers.getContractFactory('PoolNode')).attach(addrObj.poolNodeAddress);
    r = await contract.receiveInterest();
    console.log(r);
}

module.exports.workBlcok = async() =>{
    const contract = (await ethers.getContractFactory('PoolNFT')).attach(addrObj.poolNFTAddress);
    r = await contract.workBlcok('0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4');
    console.log(r);
}

module.exports.total = async() =>{
    const contract = (await ethers.getContractFactory('PoolNode')).attach(addrObj.poolNodeAddress);
    r = await contract.total();
    console.log(r);
}

module.exports.setLPAddress = async() =>{
    const contract = (await ethers.getContractFactory('PoolLP')).attach(addrObj.poolLPAddress);
    r = await contract.setLPAddress(addrObj.lpTokenAddress);
    console.log(r);
}

module.exports.withCreator = async() =>{
    const contract = (await ethers.getContractFactory('Inviter')).attach(addrObj.inviterAddress);
    r = await contract.withCreator("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4");
    // r = await contract.admin();
    console.log(r);
}

module.exports.invest1 = async() =>{
    const contract = (await ethers.getContractFactory('Inviter')).attach(addrObj.inviterAddress);
    r = await contract.invest("0xCe772e18a9e6d51b51fFDad0aD8a1DCd9007e71A");
    // r = await contract.admin();
    console.log(r);
}

module.exports.nodeStake = async() =>{
    const contract = (await ethers.getContractFactory('PoolNode')).attach(addrObj.poolNodeAddress);
    r = await contract.stake("100000000000000000000000");
    console.log(r);
}

module.exports.nodeConfig = async() =>{
    const contract = (await ethers.getContractFactory('PoolNFT')).attach(addrObj.poolNodeAddress);
    r = await contract.config();
    console.log(r);
}

module.exports.onShelf = async() =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.onShelf(1,"100");
    console.log(r);
}

module.exports.listShelveNFTInfo = async(addr) =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.listShelveNFTInfo(addr,0,100);
    console.log(r);
}

module.exports.nftOnShelveOf = async() =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.nftOnShelveOf(1);
    console.log(r);
}

module.exports.onShelfNFT = async() =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.onShelfNFT(32,100);
    console.log(r);
}

module.exports.offShelfNFT = async() =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.offShelfNFT(1);
    console.log(r);
}

module.exports.nftApprove = async(addr) =>{
    const contract = (await ethers.getContractFactory('NFTHero')).attach(addrObj.nftHeroAddress);
    r = await contract.approve(addr,1);
    console.log(r);
}

module.exports.getApproved = async(addr) =>{
    const contract = (await ethers.getContractFactory('NFTHero')).attach(addrObj.nftHeroAddress);
    r = await contract.getApproved(1);
    console.log(r);
}

module.exports.onShelfBox = async() =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.onShelfBox(100);
    console.log(r);
}

module.exports.offShelfBox = async() =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.offShelfBox(1);
    console.log(r);
}

module.exports.listShelveBoxInfo = async() =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.listShelveBoxInfo("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4",0,100);
    console.log(r);
}

module.exports.poolNFTTotal = async() =>{
    const contract = (await ethers.getContractFactory('PoolNFT')).attach(addrObj.poolNFTAddress);
    r = await contract.total();
    console.log(r);
}

module.exports.poolNFTTotalOf = async() =>{
    const contract = (await ethers.getContractFactory('PoolNFT')).attach(addrObj.poolNFTAddress);
    r = await contract.total();
    console.log(r);
}

module.exports.nodePropOf = async() =>{
    const contract = (await ethers.getContractFactory('PoolNode')).attach(addrObj.poolNodeAddress);
    r = await contract.propOf("0xCe772e18a9e6d51b51fFDad0aD8a1DCd9007e71A");
    console.log(r);
}
module.exports.nodeStake = async() =>{
    const contract = (await ethers.getContractFactory('PoolNode')).attach(addrObj.poolNodeAddress);
    r = await contract.stake("100000000000000000000000");
    console.log(r);
}

module.exports.listTransactionRecord = async() =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.listTransactionRecord("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4",0,99,1);
    console.log(r);
}
module.exports.buyNFT = async() =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.buyNFT(26);
    console.log(r);
}

module.exports.buyNFT = async() =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.buyNFT(26);
    console.log(r);
}
module.exports.rarityAmountExchange = async() =>{
    const contract = (await ethers.getContractFactory('PoolNFT')).attach(addrObj.poolNFTAddress);
    r = await contract.rarityAmount("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4",1);
    console.log(r);
}

module.exports.nftAmountRarityOf = async() =>{
    const contract = (await ethers.getContractFactory('PoolNFT')).attach(addrObj.poolNFTAddress);
    r = await contract.nftAmountRarityOf("0xCe772e18a9e6d51b51fFDad0aD8a1DCd9007e71A",4);
    console.log(r);
}

module.exports.nftOnShelveOwnerOf = async() =>{
    const contract = (await ethers.getContractFactory('Exchange')).attach(addrObj.exchangeAddress);
    r = await contract.nftOnShelveOwnerOf(10);
    console.log(r);
}

module.exports.getPendingHF = async() =>{
    const contract = (await ethers.getContractFactory('PoolHF')).attach(addrObj.poolHFAddress);
    r = await contract.getPending("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4",2);
    console.log(r);
}


module.exports.receiveAmountByAdmin = async() =>{
    const contract = (await ethers.getContractFactory('PoolHF')).attach(addrObj.poolHFAddress);
    r = await contract.receiveAmountByAdmin();
    console.log(r);
}

module.exports.getPendingHF = async() =>{
    const contract = (await ethers.getContractFactory('PoolHF')).attach(addrObj.poolHFAddress);
    r = await contract.getPending("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4",2);
    console.log(r);
}

module.exports.authPoolHF = async() =>{
    const contract = (await ethers.getContractFactory('PoolHF')).attach(addrObj.poolHFAddress);
    r = await contract.changeWeight("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4");
    console.log(r);
}

module.exports.allowance = async() =>{
    const contract =  (await ethers.getContractFactory("ERC20Token")).attach(addrObj.psTokenAddress);
    r = await contract.allowance("0xAfB1306976cA6a4Cf55253EE217B50A05394D0F2",addrObj.airdropAddress);
    console.log(r);
}

module.exports.creatorAirdropInfoList = async() =>{
    const contract =  (await ethers.getContractFactory("Airdrop")).attach(addrObj.airdropAddress);
    r = await contract.lpAirdropInfoList(5,1);
    console.log(r);
}

module.exports.totalNode = async() =>{
    const contract =  (await ethers.getContractFactory("PoolNode")).attach(addrObj.poolNodeAddress);
    r = await contract.propOf("0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    console.log(r);
}

module.exports.authCheck = async() =>{
    const contract =  (await ethers.getContractFactory("Check")).attach(addrObj.checkAddress);
    // r = await contract.propOf("0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    // r = await contract.setAuth("0x00e11357307e25DC9edf7518BD54310Fbf007068", true)
    // r = await contract.setAuth("0x9bB581bcE37ecEa8dd86340dc355cFb2Be033f51", true)
    r = await contract.setAuth("0xD5263369aCFe184DDdeD9e73B55135bB7aD94299", true)
    console.log(r);
}
module.exports.listMember = async() =>{
    const contract = (await ethers.getContractFactory('PoolLP')).attach(addrObj.poolLPAddress);
    r = await contract.listMember(0,5);
    // r = await contract.admin();
    console.log(r);
}

module.exports.memberListAdd = async() =>{
    const contract = (await ethers.getContractFactory('Inviter')).attach(addrObj.inviterAddress);
    // console.log(addrObj.inviterAddress);
    list = [
        "0x43052796Da34A92FCE81318dC42937537A29F417",
        // "0x5d4658b9bf8af7bce61199949c1f612c8230b251",
        // "0xfad455ae831d195828946436c2b4fa787a7a93bc",
        // "0x57e30bd491f8aa942ad694efa0ba87db4dd32cb3",
        // "0x68bf9b24f747fe999a9eeaa9523304b56fa5022d",
        // "0x9c6a348d7dd03a9d3ffd5db23f5cf1ae513eea3f",
        // "0xbe6565ad1510013f44ddf7ff1abac1d5f5ad265a",
        // "0x471a9ecc73a304a67ad0020b8d09f4f4840e124e",
        // "0x6a2464da94537b24e9effd8642850122d67db59f",
        // "0x694722c32c8bc83d89bb6950dcba74a801e23551",
        // "0xad84b9d29f365bf8e0d8ff8e39a71d509fa31d08",
        // "0x7b447dfa98d49bcf476073fd2544944193297c49",
        // "0x1e1759e5150a6e8945c6b67ddf8292205fcdfd97",
        // "0x5dba7cdc6b2a9f41fd4dfd6d1272573c6f94bc26",
        // "0x1fe5ad15dd0817bb7a976e396fb2ef12e9e92a25",
        // "0xaf3a282685b0b40022b6080d63c8b46fb4f5f84e",
        // "0xd6d8f4fdfc3159114eb9b9a49384702bf859bde3",
        // "0x2d05e9866e1ef6058bfb146157c5f4142748f734",
        // "0x3c89fdd68aca8a40d6d6e6788d0385712e37ffa0",
        // "0x25ace85c22dfb6c18bed741caa983fd10920fd02",
        // "0xfeddc05fb1064c97105719cf9251fd852284f1fa",
        // "0x5d53c2a69486d9314961feba7bf03b47c6563ae7",
        // "0x4a2b5a464d38cda9bd48d924add1396183d3903d",
        // "0x2e7b16a8a33748a02f6f04ab1f635deb102c6f30",
        // "0x06602504a904487b6c2b641c5819932bc4a54ee0",
        // "0xb7dc908bec6d6c179188fa53a54fe7650a4c5eed",
        // "0xea35b1bedfa4ca2787d9052c2b90f3d60aaf9cef",
        // "0xe209f78ad7dc9c2285042d70b28d047bfbda9484",
        // "0x21f40702fd5cc567e06f178e3bd81ba99010742e",
        // "0xa346dcfcce50470ba2d5f197b6445628ed5cc8fb",
        // "0x1793ee86ab095623efe218d08aa1d08dba50f4a3",
        // "0xa00d504ac9714b885b7740cbc7be876dc99bb678",
        // "0x4db48d1b9546e4b0ebcb2b9cfdfc922f1b2520d8",
        // "0x63dfc5d1357f0a8bb8384683a00f3e65bab4b8a6",
        // "0x30f598dee5d0249b381fb57957e2c36c02d9528b",
        // "0x73c87628d95909fe27978c5d5784c073d60e559f",
        // "0x78515baa2f798708b4f0cd818e0b2e65f5e7ee01",
        // "0xb0e0183573c1d4e54bb5718c56d4ae1cebb8d241",
        // "0x9180e2a5f60e7913f6387e8c9cf6ebe808a9b543",
        // "0x78e9d4b3f3a6501517871271d41498807f3329ac",
        // "0x7903c60934074b53e1a8bfca76cc809e6c405845",
        // "0x0187f8867c706911ce4dada494d285a2f54bc5de",        
    ]
    r = await contract.memberListAdd(list);
    // r = await contract.admin();
    console.log(r);
}

module.exports.listReceiveRecord = async() =>{
    const contract = (await ethers.getContractFactory('PoolNode')).attach(addrObj.poolNodeAddress);
    r = await contract.listReceiveRecord("0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4",0,5);
    console.log(r);
}


module.exports.addAirdrop = async() =>{
    const contract =  (await ethers.getContractFactory("Airdrop")).attach(addrObj.airdropAddress);
    // console.log('setConfig -------------------------------- ')
    // r = await contract.setConfig(addrObj.configBaseAddress)

    console.log('Assets setAuth ---------------------------------')
    const assets = (await ethers.getContractFactory('Assets')).attach(addrObj.assetsAddress)
    r = await assets.setAuth(contract.address, true)
    console.log(r);
}

module.exports.idoInfoOf = async() =>{
    const contract = (await ethers.getContractFactory('IDo')).attach(addrObj.idoAddress);
    r = await contract.idoInfoOf("0x20ee59dFB91216EDE794eC12c5CF259c181FA9f3");
    console.log(r);
}

module.exports.accountTeamAmountOf = async() => {
    const contract = (await ethers.getContractFactory('Inviter')).attach(addrObj.inviterAddress);
    // r = await contract.accountTeamAmountOf("0x286476a14dc9d9070e9375DCaa4a683316432c11");
    // r = await contract.getMemberCount();
    // 0x02b5426bD3751DC6a41C5ddB7569d2a8953Af595
    // 0xebB5a3F922d0D4294ADA0ac82478815115847F8a
    // r = await contract.stakeCountOf("0xebB5a3F922d0D4294ADA0ac82478815115847F8a");
    
    r = await contract.getTeamCount("0x286476a14dc9d9070e9375DCaa4a683316432c11");
    // r = await contract.getChildCount("0x82f41613a6c0e85112e255e301378e90656848ca");
    // r = await contract.childsOf("0x82f41613a6c0e85112e255e301378e90656848ca",0);
    console.log(r);
}

module.exports.stakeCountOf = async() => {
    const contract = (await ethers.getContractFactory('Inviter')).attach(addrObj.inviterAddress);
    r = await contract.stakeCountOf("0x7e3e05a48e208daa2311567473c0bcee98f910d4");
    // r = await contract.getMemberCount();
    // r = await contract.getTeamCount("0x286476a14dc9d9070e9375DCaa4a683316432c11");
    console.log(r);
}

module.exports.ERC20TokenNotUpgrade = async() => {
    const contract = (await ethers.getContractFactory('ERC20TokenNotUpgrade')).attach("0xc8dfa3379a00C00CF033CE566AD13b93f9ACB636");
    // r = await contract.accountTeamAmountOf("0x286476a14dc9d9070e9375DCaa4a683316432c11");
    // r = await contract.getMemberCount();
    r = await contract.addWhiteList("0x76D780b445EE3383c0aE979080a7B30bD0dafE1F");
    r = await contract.addWhiteList("0x3AfF13e456BB87eA269345Be32Df3c7Bc33Fa83E");
    r = await contract.addWhiteList("0xe62053ece0c965C9f7034114ea791B251cED59Ee");
    r = await contract.addWhiteList("0x912D42fB6288e851955061E3D9e70f095BF3732d");
    r = await contract.addWhiteList("0x2Ac86E09966061453f210D15BaF34804FB74eBC9");
    console.log(r);
}

module.exports.checkTest = async() =>{
    const contract =  (await ethers.getContractFactory("Check")).attach(addrObj.checkAddress);
    // r = await contract.propOf("0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    r = await contract.test("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4")
    console.log(r);
}

module.exports.liststakeNFTInfo = async() =>{
    const contract = (await ethers.getContractFactory('PoolNFT')).attach(addrObj.poolNFTAddress);
    // r = await contract.getPending("0x0D56fe32a9DfeC571d42A837366C69e119FE1974");
    r = await contract.nftAmountRarityOf("0x4182B94A4d6e54Ae50719DC87B77bF0293688fAf",1);
    // r = await contract.liststakeNFTInfo("0x4182B94A4d6e54Ae50719DC87B77bF0293688fAf",0,5)
    console.log(r);
}

module.exports.listConversionInfo = async() =>{
    const contract = (await ethers.getContractFactory('Conversion')).attach(addrObj.conversionAddress);

    r = await contract.listConversionInfo(0,5);
    // r = await contract.newTokenAmountOf("0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4");
    // r = await contract.liststakeNFTInfo("0x4182B94A4d6e54Ae50719DC87B77bF0293688fAf",0,5)
    console.log(r);
}

module.exports.getPrice = async() =>{
    const usdt =  (await ethers.getContractFactory("ERC20Token")).attach(addrObj.usdtTokenAddress);
    const tcoin =  (await ethers.getContractFactory("ERC20Token")).attach(addrObj.psTokenAddress);
    const lp =  (await ethers.getContractFactory("ERC20Token")).attach(addrObj.lpTokenAddress);
    const lpAmount = await lp.totalSupply()
    // const usdtAmount = await usdt.balanceOf("0xe73C45077EACc3e435BB7de1aA15C4636d33Aa61")
    // const tcoinAmount = await tcoin.balanceOf("0xe73C45077EACc3e435BB7de1aA15C4636d33Aa61")
    // const r = tcoinAmount/usdtAmount;
    // console.log(usdtAmount);
    // console.log(tcoinAmount);
    console.log(lpAmount);
}
// this.liststakeNFTInfo()
// this.receiveAmountByAdmin();
// this.getPrice();
// this.checkTest();
// this.accountTeamAmountOf();
// this.listReceiveRecordPoolHF();
// this.idoInfoOf();
// this.listReceiveRecord();
// 0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4
// this.authCheck()
// this.memberListAdd();
// this.listMember();

// this.erc20SetLPAddress();
// this.nftHeroConfig();
// this.totalNode();
// this.creatorAirdropInfoList();
// this.allowance();

// this.getPendingHF();
// this.nftOnShelveOwnerOf()
// this.buyNFT();
// this.listTransactionRecord();
// a07a9ffbe56424c1bca9dbaf83a88667c4f4866a396f3b1b894b7ad294bf2ab1
// this.nodeStake();
// this.nodePropOf();
// this.poolNFTTotal();
// this.listShelveBoxInfo();
// this.offShelfBox();
// this.onShelfBox();
// this.approve();
// this.getApproved(addrObj.exchangeAddress);
// this.onShelfNFT();
// this.offShelfNFT();
// this.nftOnShelveOf()
// this.listShelveNFTInfo("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4");
// this.ownerOf();
// this.onShelf();
// this.nodeConfig();
// this.nodeStake();
// this.withCreator();

// this.setLPAddress();// 0xCe772e18a9e6d51b51fFDad0aD8a1DCd9007e71A
// '0xC848dE73EE3B61bdFc9E3c9488837a992eDAfFB9', '0xcfd1586c1fdb6e377533c902bd2ced0ce500def4'
// this.total();
// this.workBlcok();
// this.lpConfig();
// this.receiveInterest();
// this.stake();
// this.setConfig();
// this.setConfigUint() 
// this.getPending()
// this.listLpInfo();
// this.setlpArrays();
// this.setAsset();
// this.inviterConfig();
// this.listSubInfo();
// this.admin();
// this.airdropTcoinToAccount();
// this.airdropConfig();
// this.receiveAmount();
// this.listInvsetInfo();
// this.invest();
// this.setConfigNameOf();
// this.listIDoInfo();
this.auth("Airdrop",addrObj.airdropAddress,"0xD5263369aCFe184DDdeD9e73B55135bB7aD94299")
// this.auth("IDo",addrObj.idoAddress,"0x0d39b59D2FFBA4a7f703fFb446A28417F6d21e71")
// this.auth("PoolHF",addrObj.poolHFAddress,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4")
// this.auth("PoolHF",addrObj.poolHFAddress,"0x0d39b59D2FFBA4a7f703fFb446A28417F6d21e71")
// this.auth("Check",addrObj.checkAddress,"0x50e3E0F9D048C52AeeC078a82777D60B584DE8e4")
// this.auth("Assets",addrObj.assetsAddress,"0x0d39b59D2FFBA4a7f703fFb446A28417F6d21e71");
// this.startIDo();
// this.endIDo();
// this.freeze();
// this.tokenRarity();
// this.openBoxByAdmin();

// this.getNFTs("0xcfd1586C1fDb6E377533c902bD2ceD0CE500deF4");
// this.getNFTs("0xCe772e18a9e6d51b51fFDad0aD8a1DCd9007e71A");
// this.getNFTs("0x70997970C51812dc3A010C7d01b50e0d17dc79C8");
// this.authCheck();
// this.hfauth();
// this.transferFrom()
// this.openBox();
// this.setAsset();
// this.assetsOf();
// this.updateStorage();
// this.setConfigUint()
// this.config("nftHero");  
// this.authPoolHF()
// this.rarityAmountExchange();
// this.setConfigNameOf();
// this.propOf("0x5d9f6698566bd42423d3a0d7f43901dd2b2b9849");
// this.upgrade("Inviter",addrObj.inviterAddress)
// this.upgrade("IDo",addrObj.idoAddress)
// this.upgrade("NFTBox",addrObj.nftBoxAddress)
// this.upgrade("Airdrop",addrObj.airdropAddress);
// this.mintTimeOf();
// this.upgrade("NFTHero",addrObj.nftHeroAddress)
// this.upgrade("PoolLP",addrObj.poolLPAddress)
// this.upgrade("PoolNode",addrObj.poolNodeAddress)
// this.upgrade("ConfigBase",addrObj.configBaseAddress);
// this.upgrade("PoolHF",addrObj.poolHFAddress)
// this.upgrade("Conversion",addrObj.conversionAddress);
// this.upgrade("Check",addrObj.checkAddress)
// this.upgrade("PoolNFT",addrObj.poolNFTAddress)
// this.listAirdropRecord();
// this.upgrade("Exchange",addrObj.exchangeAddress)
// this.upgrade("ERC20Token",addrObj.psTokenAddress)
// this.listConversionInfo();
// this.nftAmountRarityOf();
// this.addAirdrop()
// this.ERC20TokenNotUpgrade();
// this.stakeCountOf();0x83b83de0C99109C202deeFf7543dC226edF44192